const express = require('express');
const router = express.Router();
const { 
  registerUser, 
  loginUser, 
  getUserProfile, 
  updateUserProfile,
  addBookmark,
  removeBookmark,
  addNote,
  updateNote,
  deleteNote,
  updateProgress,
  recordExercise,
  getLearningReport,
  cleanupUserData,
  getUserStats,
  getBookmarks,
  getNotes
} = require('../controllers/userController');
const { protect } = require('../middlewares/auth');

// 公开路由
router.post('/register', registerUser);
router.post('/login', loginUser);

// 私有路由 - 需要身份验证
router.get('/profile', protect, getUserProfile);
router.put('/profile', protect, updateUserProfile);

// 书签路由
router.get('/bookmarks', protect, getBookmarks);
router.post('/bookmarks', protect, addBookmark);
router.delete('/bookmarks/:cardId', protect, removeBookmark);

// 笔记路由
router.get('/notes', protect, getNotes);
router.post('/notes', protect, addNote);
router.put('/notes/:noteId', protect, updateNote);
router.delete('/notes/:noteId', protect, deleteNote);

// 学习进度路由
router.put('/progress', protect, updateProgress);

// 练习记录路由
router.post('/exercises', protect, recordExercise);

// 学习报告路由
router.get('/report', protect, getLearningReport);

// 数据清理路由
router.delete('/data', protect, cleanupUserData);

// 用户统计数据路由
router.get('/stats', protect, getUserStats);

module.exports = router; 